<!-- 创建账户 -->
<template>
    <div class="crumbs">
    <crumbs></crumbs>
    </div>
    <el-form  label-width="100px" :model="formInline" class="demo-form-inline">
        <el-form-item label="企业用户名">
        <el-input style="width: 300px;margin-bottom: 20px" v-model="formInline.username" placeholder="企业用户名" />
      </el-form-item>
      <el-form-item label="企业密码">
        <el-input style="width: 300px;margin-bottom: 20px" v-model="formInline.password" placeholder="企业密码" />
      </el-form-item>
      <el-form-item label="企业手机号">
        <el-input style="width: 300px;margin-bottom: 20px" v-model="formInline.phone" placeholder="企业手机号" />
      </el-form-item>
      <el-form-item label="验证码">
        <el-input style="width: 300px;margin-bottom: 20px" v-model="formInline.code" placeholder="验证码" />
      </el-form-item>
      <img
                align="left"
                style="margin-left:100px"
                ref="vcImg"
                :src=imgSrc
                title="点击换一张"
                alt="验证码"
                @click="getVerifCode()"
        />
    </el-form>
    <div class="part">
      <el-button @click="confirm">确认</el-button>
      <el-button @click="close">关闭</el-button>
    </div>
  </template>
  
  <script>
  import { reactive,ref } from 'vue'
  import crumbs from '../../user management/crumb/crumb.vue'
  import {useStore} from 'vuex'
  import {useRouter,useRoute} from 'vue-router'
  import axios from 'axios'
  export default {
     name: "reset",
     components:{
        crumbs,   
    },
     setup(){
      const store=useStore();
      const router=useRouter();
      const route=useRoute()
  const close = () => {
        router.push('/account')
    }
    const formInline = reactive({
      username: '',
      password: '',
      phone:'',
      code:'',
  })
  let imgSrc=ref("http://1.14.73.59:8080/enterprise/sendcode")
  const getVerifCode=()=>{
    let time=new Date()
    let img=`http://1.14.73.59:8080/enterprise/sendcode?date=${time}`
   imgSrc.value=img
    console.log(time)
        axios({
          url:'http://1.14.73.59:8080/enterprise/sendcode',
          method:'post'

        }).then(resp=>{

        })
  }
  const confirm=()=>{
    router.push('/account')
    axios({
      url:'http://1.14.73.59:8080/enterprise/addEnterpriser',
      method:"post",
      params:{
        code:formInline.code,
        id:route.query.id,
        password:formInline.password,
        phone:formInline.phone,
        username:formInline.username,
      }
    }).then(resp=>{
        console.log(resp.data)
    })
  }
    return {
        formInline,
        close,
        store,
        router,
        confirm,
        route,
        getVerifCode,
        imgSrc
  }
           
      }
  }
  </script>
  <style scoped>
   .crumbs{
  margin-bottom:20px;
 }
 .part{
  margin-top:100px;
 }
 </style>
  